//Khai bao thu vien
#include<conio.h>
#include<stdio.h>
//Ham ve tam giac vuong
void tgv(int n)
{
	//Xoa man hinh
	clrscr();
	for (int i=1;i<=n;i++)
	{
		gotoxy(40,6+i);
		for (int j=1;j<=2*i-1;j++)
			printf("*");
	}
}
//Ham ve tam giac vuong rong
void tgvr(int n)
{
	//Xoa man hinh
	clrscr();
	for (int i=1;i<=n;i++)
	{
		gotoxy(40,6+i);
		for (int j=1;j<=2*i-1;j++)
		{
			if(i==1||i==n||j==1||j==2*i-1)
				printf("*");
			else
				printf(" ");
		}
	}

}
//Ham ve tam giac bang ki tu * va [
void tgv3(int n)
{
	//Xoa man hinh
	clrscr();
	for (int i=1;i<=n;i++)
	{
		gotoxy(40,6+i);
		for (int j=1;j<=2*i-1;j++)
			if(j%2==0&&i!=n)
				printf("[");
			else
				printf("*");
	}
}

//Ham menu tam giac
void menu(int &chon)
{
	printf("\n\t1.Ve tam giac vuong");
	printf("\n\t2.Ve tam giac vuong rong");
	printf("\n\t3.Ve tam giac vuong bang ki tu * va [");
   	printf("\n\t0.Thoat");
	printf("\n\tNhap tam giac can ve:");
	scanf("%d",&chon);
}

void main()
{
	int h,chon;
	clrscr();
	printf("\n\tCHUONG TRINH VE TAM GIAC\n");
	do
	{
		clrscr();
		//Goi ham menu
		menu(chon);
		switch (chon)
		{
			//Ve tam giac vuong dac
			case 1:
				printf("\n\tNhap chieu cao tam giac:");
				scanf("%d",&h);
				tgv(h);
				break;
			//Ve tam giac vuong rong
			case 2:
				printf("\n\tNhap chieu cao tam giac:");
				scanf("%d",&h);
				tgvr(h);
				break;
			//Ve tam giac bang ki tu * va [
			case 3:
				printf("\n\tNhap chieu cao tam giac:");
				scanf("%d",&h);
				tgv3(h);
				break;
		}
		getch();
	}
   while (chon!=0);
}
